package com.zjitc;

import com.zjitc.config.JavaConfigDemo1;
import com.zjitc.config.JavaConfigDemo2;
import com.zjitc.obj.Teacher;
import com.zjitc.obj.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/6 15:48
 * @description:
 */
public class App3 {

  public static void main(String[] args) {

    // new ClassPathXmlApplicationContext("...xml");
    // 理论上的是 dan li 对象
    ApplicationContext context = new AnnotationConfigApplicationContext(JavaConfigDemo2.class);
    User u1 = context.getBean("user", User.class);
    User u2 = context.getBean("user", User.class);
    Teacher t1 = context.getBean("teacher", Teacher.class);

    if (u1.equals(u2)) { System.out.println("equal"); }
    System.out.println(u1);
    System.out.println(t1);
  }
}
